package com.ruoyi.hydrology.service.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.hydrology.domain.Yslcdss;
import com.ruoyi.hydrology.dto.HydrologyDto;
import com.ruoyi.hydrology.mapper.YslcdssMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hydrology.mapper.YslcddyMapper;
import com.ruoyi.hydrology.domain.Yslcddy;
import com.ruoyi.hydrology.service.IYslcddyService;

/**
 * 涌水量基础信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@Service
public class YslcddyServiceImpl extends ServiceImpl<YslcddyMapper, Yslcddy> implements IYslcddyService //修改
{
    @Autowired
    private YslcddyMapper yslcddyMapper;
    @Autowired
    private YslcdssMapper yslcdssMapper;
    /**
     * 查询涌水量基础信息
     * 
     * @param id 涌水量基础信息主键
     * @return 涌水量基础信息
     */
    @Override
    public Yslcddy selectYslcddyById(String id)
    {
        return yslcddyMapper.selectYslcddyById(id);
    }

    /**
     * 查询涌水量基础信息列表
     * 
     * @param yslcddy 涌水量基础信息
     * @return 涌水量基础信息
     */
    @Override
    public List<Yslcddy> selectYslcddyList(Yslcddy yslcddy)
    {
        return yslcddyMapper.selectYslcddyList(yslcddy);
    }

    /**
     * 新增涌水量基础信息
     * 
     * @param yslcddy 涌水量基础信息
     * @return 结果
     */
    @Override
    public int insertYslcddy(Yslcddy yslcddy)
    {
        return yslcddyMapper.insertYslcddy(yslcddy);
    }

    /**
     * 修改涌水量基础信息
     * 
     * @param yslcddy 涌水量基础信息
     * @return 结果
     */
    @Override
    public int updateYslcddy(Yslcddy yslcddy)
    {
        return yslcddyMapper.updateYslcddy(yslcddy);
    }

    /**
     * 批量删除涌水量基础信息
     * 
     * @param ids 需要删除的涌水量基础信息主键
     * @return 结果
     */
    @Override
    public int deleteYslcddyByIds(String[] ids)
    {
        return yslcddyMapper.deleteYslcddyByIds(ids);
    }

    /**
     * 删除涌水量基础信息信息
     * 
     * @param id 涌水量基础信息主键
     * @return 结果
     */
    @Override
    public int deleteYslcddyById(String id)
    {
        return yslcddyMapper.deleteYslcddyById(id);
    }

    @Override
    public Yslcddy selectYslcddyByCode(String code) {
        return yslcddyMapper.selectYslcddyByCode(code);
    }

    @Override
    public List<HydrologyDto> getHydrology() {
        List<HydrologyDto> yslcddies = yslcddyMapper.getHydrology();
        List<HydrologyDto> collect = yslcddies.stream().map(yslcddy -> {
            Yslcdss yslcdss = yslcdssMapper.selectYslcdssByCode(yslcddy.getStationCode());
            yslcddy.setMeasureName("涌水量");
            yslcddy.setValue(yslcdss.getValue());
            yslcddy.setMonitorTime(yslcdss.getMonitorTime());
            yslcddy.setSensorType(yslcdss.getSensorType());
            return yslcddy;
        }).collect(Collectors.toList());
        return collect;
    }
}
